package com.cswangdao.result;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

@AllArgsConstructor
@NoArgsConstructor
@Data
@Builder
public class Result <T>{

   private Integer errno;
   private T data;
   private String essmsg;

    public Result(Integer errno, String essmsg) {
        this.errno = errno;
        this.essmsg = essmsg;
    }

    public static <T> Result<T> success(T data){
       Result<T> result = new Result<>(0,data,"成功");
       return result;
   }

    public static <T> Result<T> success(){
        Result<T> result = new Result<>(0,"成功");
        return result;
    }

    public static <T> Result<T> error(){
        Result<T> result = new Result<>(1,"失败");
        return result;
    }

    public static <T> Result<T> error(String msg){
        Result<T> result = new Result<>(1,msg);
        return result;
    }
}
